/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.maze.behaviours;

import java.util.Random;

/**
 *
 * @author Thomas
 */
public class SegmentInvertionMutateBehaviour implements IMutateBehaviour{
    private static final Random rand = new Random();
    public byte[] mutate(byte[] genome) {
        if(rand.nextInt(1000)==4){
            int pos = rand.nextInt(genome.length-100);
            int pos2 = rand.nextInt(genome.length-pos-20);
            int size = rand.nextInt(20);
            byte buff;
            for(int i=0; i< size ; i++){
                buff = genome[i+pos];
                genome[i+pos]=genome[i+pos2];
                genome[i+pos2]=buff;
            }
        }
        return genome;
    }

}
